<template>
    <section class="modlude">
        <el-form :inline="true" :model="formSearch" class="form_inline" label-width="80px" size="small">
            <el-form-item label="选择区域">
                <el-select v-model="formSearch.xqId" placeholder="请选择区域">
                    <el-option v-for="(item,index) in xqTree" :label="item.name" :value="item.id" :key="index">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="非法报警">
                <el-select v-model="formSearch.isAlarm" clearable>
                    <el-option label="是" :value="1"></el-option>
                    <el-option label="否" :value="0"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="开始时间">
                <el-date-picker v-model="formSearch.startTime" clearable type="datetime" value-format="timestamp"
                    placeholder="选择开始时间">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="结束时间">
                <el-date-picker clearable v-model="formSearch.endTime" type="datetime" value-format="timestamp"
                    placeholder="选择开始时间">
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button @click="getlist">查 询</el-button>
            </el-form-item>
        </el-form>
    </section>
</template>

  <script>
import paging from '../../components/paging';
import {
    getAkxDoorRecords,
    openHwDev,
    xqSelectList,
    orgTree,
} from '../../url/api';

export default {
    data() {
        return {
            option1: [],
            xqTree: [],
            isAddorUpdate: 1, //1添加、2修改
            formSearch: {
                xqId: '',
            },
            formData: [], //数据
            formUpdate: {}, //修改表单
            total: 0, //数据总数
            dataTree: [],
            defaultProps2: {
                children: 'children',
                label: 'name',
                value: 'id',
                expandTrigger: 'hover',
                checkStrictly: true,
            },
        };
    },
    methods: {
        getlist() {
            this.formSearch.current = 1;
            getAkxDoorRecords(this.formSearch).then((res) => {
                console.log(res);
                if (res.data.ok) {
                    this.formData = res.data.data.records;
                    this.total = res.data.data.total;
                    this.sendData();
                } else {
                    this.$message.error(res.data.msg);
                }
            });
        },
        getInit() {
            //初始化列表

            xqSelectList({}).then((res) => {
                //区域选择列表
                console.log(res);
                if (res.data.ok) {
                    this.xqTree = res.data.data;
                    this.formSearch.xqId = this.xqTree[0].id;
                    this.getlist();
                }
            });
            let org_tree = {
                name: '',
                status: 1,
            };
            orgTree(org_tree).then((res) => {
                //获取组织列表
                console.log(res);
                if (res.data.ok) {
                    this.dataTree = res.data.data;
                }
            });
        },
        sendData() {
            console.log('emit加载');
            this.Bus.$emit('sendTableData1', {
                formSearch: this.formSearch,
                // total:this.total
            });
        },
    },
    mounted() {
        this.getInit();
    },
    components: {
        paging,
    },
};
</script>
  <style scoped>
.form_inline {
    margin: 10px 10px 0;
}
.form_inline .el-date-editor--datetime,
.el-date-editor.el-input,
.el-date-editor.el-input__inner {
    width: 100%;
}

.cont_box {
    width: 100%;
    display: flex;
}
.cont_box_left,
.cont_box_right {
    flex: 1;
    background: transparent;
    padding: 10px;
}
.cont_box_left {
    margin-right: 10px;
}
.margin10 {
    margin-bottom: 10px;
}
.marginRight {
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
}
.cont_box_right .el-form-item {
    margin-bottom: 20px;
}
</style>
